package com.vanceinfo.ecados.common;

import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;

public class ViewAction extends Action {

	private IWorkbenchWindow window;
	private String viewId;
	private String viewName;

	public ViewAction(IWorkbenchWindow window, String viewId, String viewName) {
		this.window = window;
		this.viewId = viewId;
		this.viewName = viewName;
		setText(viewName);
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		if (window == null)
			return;
		IWorkbenchPage page = window.getActivePage();
		if (page == null)
			return;
		try {
			page.showView(viewId);
		} catch (PartInitException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
